package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Business;
import cn.wolfcode.enums.CustomerReportEnums;
import cn.wolfcode.qo.CustomerReportQuery;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ICustomerReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@RequestMapping("/customerReport")
@Controller
public class CustomerReportController {

    @Autowired
    private ICustomerReportService customerReportService;
    @Autowired
    private IBusinessService businessService;
    @RequestMapping("/list")
    public String list(CustomerReportQuery qo, Model model){
        List<Map> maps = customerReportService.customerReport(qo);
        //按年月日,门店分组
        model.addAttribute("enums", CustomerReportEnums.values());
        //返回数据
        model.addAttribute("Items",maps);
        //高级查询
        model.addAttribute("qo",qo);
        //显示门店下拉框
        List<Business> businesses = businessService.listAll();
        model.addAttribute("businesses",businesses);
        return "customerReport/list";
    }
}
